// custom-tab-bar/index.js
Component({
    data: {
        tabbarList: [{
                "icon": "home-o",
                "pagePath": "/pages/index/index",
                "text": "首页"
            },
            {
                "icon": "label-o",
                "pagePath": "/pages/topic/topic",
                "text": "专题"
            },
            {
                "icon": "cart-o",
                "pagePath": "/pages/car/car",
                "text": "购物车"
            },
            {
                "icon": "apps-o",
                "pagePath": "/pages/categroy/category",
                "text": "分类"
            },
            {
                "icon": "user-o",
                "pagePath": "/pages/user/user",
                "text": "我的"
            }
        ],
        active: 0,


    },
    methods: {
        onChange(event) {
            // event.detail 的值为当前选中项的索引
            // console.log(event.detail);
          
            wx.switchTab({
                url: this.data.tabbarList[event.detail].pagePath,
            })
         //当点击tabbar的时候，下一个页面会复制上一个页面的tabbar,会有选中状态闪烁乱跳问题
         //在每个页面使用getTabbar获取tabbar对象然后设置active的值为当前页索引即可解决该问题
         //然后这里可以注释掉
           // this.setData({
            //     active: event.detail
            // });
        },
    }
})